<%@page import="until.PageController"%>
<%@page import="until.PageController"%>
<%@page import="cn.three.eneity.Admin"%>
<%@page import="cn.three.biz.admindaobiz"%>
<%@page import="cn.three.eneity.Shop"%>
<%@page import="java.util.List"%>
<%@page import="cn.three.biz.ShopdaoBiz"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body background="../pic1/ManBgroud.gif">
<%
 //获得当前页数
 String pageIndex=request.getParameter("pageIndex");
 //如果是首页就是1
 if(pageIndex==null){
	 pageIndex="1";
 }
 //转换
 int countPage=Integer.parseInt(pageIndex);
 //每页条数
 int pageSize=4;
//获得总条数
 ShopdaoBiz biz=new ShopdaoBiz();
 int count=biz.getShopCount();
 //总页数
 PageController pc=new PageController();
 int totalPage=pc.gettotalPage(count, pageSize);
 
 //首页尾页判断
 if(countPage<1){
	countPage=1; 
 }else if(countPage>totalPage){
	 countPage=totalPage; 
 }
//分页显示pageSize每页的条数currentPage当前页数
List<Shop> list=biz.getShopByPage(countPage);


Admin admin=(Admin)session.getAttribute("admin");
%>

    <div style="height: 50px;"><h2>商品分类管理</h2></div>
    <table style="width: 80%; text-align:center; border:1px solid #006666">
   <tr>
   <th>商品类别</th>
   <th>商品标签</th>
   <th>商品名称</th>
   <th>商品价格</th>
   <th>商品细节</th>  
   <th>商品数量</th>

   <th>操作</th>
   </tr>
   <%
   request.setCharacterEncoding("UTF-8");
   response.setCharacterEncoding("UTF-8");

	for(int i=0;i<list.size();i++){
	Shop sm=list.get(i);
   %>
   <tr>
   <td><%=sm.getClassname()%></td>
   <td><%=sm.getShopId() %></td>
   <td><%=sm.getShopName() %></td>
   <td><%=sm.getShopPrice() %></td>
   <td><%=sm.getShopDetails() %></td>
   <td><%=sm.getShopCount() %></td>
   <td><a href="edit_Shop.jsp?shopid=<%=sm.getShopId()%>">编辑</a>|<a href="deletShop_servlet?shopid=<%=sm.getShopId()%>">删除</a></td> 
   </tr>
   <%} %>
   <tr>
   <td colspan="8" align="center">
   <a href="shop.jsp?pageIndex=1">首页</a>
   <a href="shop.jsp?pageIndex=<%=countPage-1 %>">上一页</a>
   <a href="shop.jsp?pageIndex=<%=countPage-1 %>">下一页</a>
   <a href="shop.jsp?pageIndex=<%=totalPage%>">尾页</a>
   </td>
   </tr>   
   </table>
   <br><br>
    <a href="/VVD/admin/addShop.jsp">新增商品信息</a>
  </body>
</html>